﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WpfStarterKit.Framework.Navigation;

namespace WpfStarterKit.Framework.Commands
{
    /// <summary>
    /// This command class is used to send users back to the parent page of a modal page
    /// </summary>
    public class BackCommand : RelayCommand
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public BackCommand()
            : base(null, null)
        {
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="execute">Execute handler called when the command is executed</param>
        public BackCommand(Action<object> execute)
            : base(execute)
        {
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="execute">Execute handler called when the command is executed</param>
        /// /// <param name="canExecute">Predicate that determines whether the command can be executed</param>
        public BackCommand(Action<object> execute, Predicate<object> canExecute)
            : base(execute, canExecute)
        {
        }

        #region ICommand Members

        /// <summary>
        /// Throws a NotImplementedException. This method should never be called because th CanExecute of this command class
        /// always returns false.
        /// </summary>
        /// <param name="parameter"></param>
        public override void Execute(object parameter)
        {
            base.Execute(parameter);
            ApplicationManager.Instance.Navigation.Back();
        }

        #endregion
    }
}
